new FastClick(document.body);
$('#username,#password').live("input propertychange", function(e) {
	$(".del_content").hide();
	e.preventDefault();
	e.stopPropagation();
	var keyword = $(this).val();
	if (keyword == "" || keyword == undefined || keyword == null) {
		$(this).next(".del_content").hide();
	} else {
		$(this).next(".del_content").css("display", "inline");
	}
});
$('.user_div').blur(function(e) {
	$(".del_content").hide();
});
$('#username,#password').bind("click", function(e) {
	e.preventDefault();
	e.stopPropagation();
	var keyword = $(this).val();
	if (keyword !== "" && keyword !== undefined && keyword !== null) {
		$(this).next(".del_content").css("display", "inline");
	}
});
$('body').bind("click", function(e) {
	// e.preventDefault();
	// e.stopPropagation();
	$(".del_content").hide();

});

var clearPsw = function() {

	var isRemember = $('#isRemember:checked').val();
	if (isRemember === undefined) {
		//alert("")
		isRemember = "false";
	}
	if (isRemember === "false") {
		$("#password").val("");
	}
};

$("#username_del").click(function() {
	$(this).parent().hide();
	$("#username").val("");
});
$("#password_del").click(function() {
	$(this).parent().hide();
	$("#password").val("");
});

$("#LoginBtn").click(function() {
	$(this).disabled = "disabled";
	var username = $("#username").val();
	var password = $("#password").val();
	var isRemember = $('#isRemember:checked').val();

	if (isRemember === undefined) {
		isRemember = "false";
	}
	cordova.exec(function(data) {
		if (data instanceof Object) {
				//alert("data 是对象");
			} else {
				//alert("data 不是对象");
				data = $.parseJSON(data);
			}
		if (data.isSuccess === true) {
			$("#LoginBtn").removeAttr("disabled");
		}
	}, function(err) {
		$("#LoginBtn").removeAttr("disabled");
	}, "CubeLogin", "login", [username, password, isRemember]);

});

var loadLogin = function() {
	var bodyHeight = $(window).height();
	$("body").css({
		'height': bodyHeight + 'px'
	});
	$("html").css({
		'height': bodyHeight + 'px'
	});
};
var app = {
	initialize: function() {
		//alert("initialize");
		this.bindEvents();
	},
	bindEvents: function() {
		document.addEventListener('deviceready', this.onDeviceReady, false);
		/*var browser = navigator.appName;
		if (browser !== "Microsoft Internet Explorer") {
			new FastClick(document.body);
		}*/
	},
	onDeviceReady: function() {
		//alert("onDeviceReady");
		app.receivedEvent('deviceready');
	},
	receivedEvent: function(id) {
		//alert("receivedEvent");
		cordova.exec(function(data) {
			if (data instanceof Object) {
				//alert("data 是对象");
			} else {
				//alert("data 不是对象");
				data = $.parseJSON(data);
			}
			$("#username").val(data.username);
			$("#password").val(data.password);
			//alert(data.isRemember+"");
			if (data.isRemember === true) {
				$("#isRemember").attr("checked", 'checked');
			}

		}, function(err) {
			alert(err);
		}, "CubeLogin", "getAccountMessage", []);
	}
};
app.initialize();